using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Bee : Enemy {

    [Header("移动范围")]
    public float patrolRadius;

    protected override void Awake() {
        base.Awake();
        patrolState = new BeePatrolState();
        chaseState = new BeeChaseState();
    }

    public override bool FoundPlayer() {
        var obj = Physics2D.OverlapCircle(transform.position, checkDistance, attackLayer);
        if (obj) {
            attacker = obj.transform;
        }
        return obj;
    }

    public override void Move() {
        // Bee的移动在状态机里实现
    }

    public override Vector3 GetNewPoint() {
        // 移动半径内随机一个dx和dy
        float dx = Random.Range(-patrolRadius, patrolRadius);
        float dy = Random.Range(-patrolRadius, patrolRadius);
        // 以出生点为基准移动(dx,dy)
        return base.spwanPoint + new Vector3(dx, dy);
    }

    public override void OnDrawGizmosSelected() {   // 测试：绘制检测范围
        // 追击检测范围
        Gizmos.DrawWireSphere(transform.position, checkDistance);
        Gizmos.color = Color.green;
        // 巡逻移动半径范围
        Gizmos.DrawWireSphere(transform.position, patrolRadius);
    }

}
